//
//  HomeStatistics3PLDetailVC.m
//  ReceiptDelivery
//
//  Created by 吕晶 on 2021/6/25.
//  Copyright © 2021 吕晶. All rights reserved.
//

#import "HomeStatistics3PLDetailVC.h"
#import "Statistics3PLModel.h"
#import "Statistics3PLDetailCell.h"

@interface HomeStatistics3PLDetailVC () <UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) Statistics3PLModel *model;

@end

@implementation HomeStatistics3PLDetailVC

-(UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenW, ScreenH - NaviHeight - BottomHeight)];
        _tableView.backgroundColor = Color_backgroundColor;
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    }
    return _tableView;
}

-(Statistics3PLModel *)model {
    if (!_model) {
        _model = [Statistics3PLModel new];
    }
    return _model;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = self.name;
    [self.view addSubview:self.tableView];
    [self requestForData];
}

- (void)requestForData {
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    [dic setObject:@(self.Id) forKey:@"id"];
    [HttpRequest PostWithApi:LogisticsSupplierHome3PLDetail_V_1_0 params:dic progress:^(NSProgress * _Nonnull progress) {

    } success:^(NSURLSessionDataTask * _Nonnull operation, id  _Nonnull responseObject, BOOL code, NSInteger errorCode) {
        if (code) {
            self.model = [Statistics3PLModel mj_objectWithKeyValues:responseObject];
            [self.tableView reloadData];
        }
    } fail:^(NSError * _Nonnull error) {

    }];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    Statistics3PLDetailCell *cell = [Statistics3PLDetailCell Statistics3PLDetailCellWithTableView:tableView];
    cell.model = self.model;
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    Statistics3PLDetailCell *cell = [Statistics3PLDetailCell Statistics3PLDetailCellWithTableView:tableView];
    cell.model = self.model;
    return cell.height;
}

@end
